Component({
  data: {
    selected: 0,
    color: "#FFFFFF",
    selectedColor: "#FFFFFF",
    list: [{
      "pagePath": "/pages/index/index",
      "iconPath": "/images/70/home1.png",
      "selectedIconPath": "/images/70/home1.png",
      "text": "首页"
    },
      {
        "pagePath": "/pages/scan/index",
        "iconPath": "/images/70/vr.png",
        "selectedIconPath": "/images/70/vr.png",
        "text": "全景展"
      },
      {
        "pagePath": "/pages/scan/index",
        "iconPath": "",
        "selectedIconPath": "",
        "text": ""
      },
      {
        "pagePath": "/pages/scancode/index",
        "iconPath": "/images/70/sign.png",
        "selectedIconPath": "/images/70/sign.png",
        "text": "打卡"
      },
      {
        "pagePath": "/pages/share70/index",
        "iconPath": "/images/70/share.png",
        "selectedIconPath": "/images/70/share.png",
        "text": "分享"
      }]
  },
  attached() {
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const index = e.currentTarget.dataset.index
      if(index == 2){
        wx.scanCode({
          onlyFromCamera: false,
          scanType: ['qrCode', 'barCode'],
          success: function (res) {
            // console.log(res.result);
            wx.navigateTo({
              url: "/pages/audio_progress/index?voice=" + res.result
            });

          },
          fail: function (err) {
            console.log(err);
          },
          complete: function (res) {
            console.log(res);
          }
        })
      }else{
        const url = data.path
        wx.switchTab({ url })
      }
      
      this.setData({
        selected: data.index
      })
    }
  }
})